{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "75ef1cbf",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "haha 5\n",
      "haha 10\n",
      "haha 15\n",
      "haha 20\n",
      "haha 25\n",
      "haha 30\n",
      "haha 35\n",
      "haha 40\n",
      "haha 45\n",
      "haha 50\n",
      "haha 55\n",
      "haha 60\n",
      "haha 65\n",
      "haha 70\n",
      "haha 75\n",
      "haha 80\n",
      "haha 85\n",
      "haha 90\n",
      "haha 95\n",
      "haha 100\n",
      "请输入您的账号：luoyu\n",
      "请输入您你的密码：123456\n"
     ]
    },
    {
     "ename": "NameError",
     "evalue": "name 'password_data' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-1-3573c8bc870a>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m     26\u001b[0m   \u001b[1;31m# 1. 先判断账号\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     27\u001b[0m   \u001b[1;32mif\u001b[0m \u001b[0muser_data\u001b[0m \u001b[1;33m==\u001b[0m \u001b[0musername\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 28\u001b[1;33m         \u001b[1;32mif\u001b[0m \u001b[0mpassword_data\u001b[0m \u001b[1;33m==\u001b[0m \u001b[0mpassword\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     29\u001b[0m             \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"欢迎\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0musename\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34m\"登录系统使用\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     30\u001b[0m             \u001b[1;32mbreak\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mNameError\u001b[0m: name 'password_data' is not defined"
     ]
    }
   ],
   "source": [
    "# Author:luoyu\n",
    "# 时间：0923-week4\n",
    "\n",
    "#登录系统\n",
    "#用户输入的数据 VS 数据库的数据\n",
    "# 优化 ： 1. 输入不正确时继续输入。 2.设置输入失败的次数\n",
    "\n",
    "# while True+count计数器 VS for循环+range()\\\n",
    "#white True+结束条件\n",
    "count = 0\n",
    "while True:\n",
    "    # count = count+1\n",
    "    count +=5\n",
    "    print(\"haha\",count)\n",
    "    if count == 100:\n",
    "        break\n",
    "# 模拟数据库数据\n",
    "user_data = \"luoyu\"\n",
    "user_password = \"123456\"\n",
    "count=3\n",
    "while True:\n",
    "  count-=1\n",
    "  # 用户输入数据\n",
    "  username = input(\"请输入您的账号：\")\n",
    "  password = input(\"请输入您你的密码：\")\n",
    "  # 1. 先判断账号\n",
    "  if user_data == username:\n",
    "        if password_data == password:\n",
    "            print(\"欢迎\",usename,\"登录系统使用\")\n",
    "            break\n",
    "        else:\n",
    "            if count == 0:\n",
    "                print(\"你都输入3次了还错,5分钟再来吧笨蛋\")\n",
    "                break\n",
    "            else:\n",
    "                print(\"您输入的账号或密码不正确，请重新输入,你还有“,count,”次机会\")\n",
    "  else:\n",
    "        if count == 0:\n",
    "            print(\"你都输入3次了还错,5分钟再来吧笨蛋\")\n",
    "            break\n",
    "        else:\n",
    "            print(\"您输入的账号或密码不正确，请重新输入,你还有“,count,”次机会\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "493a774a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
